package com.yunji.cabinet.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.yunji.cabinet.domain.MaintainDO;
import com.yunji.cabinet.params.RecordParam;
import com.yunji.cabinet.vo.MaintainVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.cabinet.mapper
 * @Title: IMaintainMapper
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-11-01 14:56:06      V1.0        HuaAo       新建类
 */

public interface IMaintainMapper extends MPJBaseMapper<MaintainDO> {

    @Select("<script> select tm.*,tms.site_id as siteId,tms.agent_id as agentId from tl_maintain tm " +
            " left join tm_site_location tms on tm.location_id = tms.location_id where tm.del_flag =0 and tm.maintain_status =1" +
            " <if test='containerId != null'> and tm.container_id = #{containerId}  </if>" +
            " <if test='maintainType != null'>" +
            " <if test='maintainType == 0'> and change_volt = 0 </if> " +
            " <if test='maintainType == 1'> and change_volt = 1 </if>  </if> " +
            " <if test='siteId != null'> and tms.site_id = #{siteId} </if>" +
            " <if test='agentId != null'> and tms.agent_id = #{agentId} </if> " +
            " <if test='staffName != null'> and tm.staff_name like concat('%',#{staffName},'%') </if>" +
            " <if test='locationName != null'> and tms.location_name like concat('%',#{locationName},'%') </if>" +
            " <if test='startTime != null'> and tm.start_time &gt;= #{startTime} </if>" +
            " <if test='endTime != null'> and tm.start_time &lt;= #{endTime} </if>" +
            " ${orderSql}</script>")
    List<MaintainVO> searchPageList(RecordParam param);

    @Select("select chip_imei from tl_maintain where maintain_code = #{maintainCode} ")
    String getImeiByMaintainCode(String maintainCode);
}